<?php

namespace App\Listeners;

use App\Events\OrderRepairSuccessEvent;
use App\Model\Admin;
use App\Model\Repair;
use WechatService;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class OrderRepairSuccessListener
{

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
    }

    /**
     * Handle the event.
     *
     * @param  RepairEvent  $event
     * @return void
     */
    public function handle(OrderRepairSuccessEvent $event)
    {
        $data = [
            'first' => '你好，计协维护人员已受理你的维护预约！',
            'keyword1' => $event->user->name,
            'keyword2' => $event->user->cellphone,
            'keyword3' => strval($event->repair->updated_at),
            'remark' => '请自行联系或耐心等待!'
        ];
        WechatService::sendNotice($data, env('APP_URL').'repair', $event->repair->open_id, 'receive_order');
    }
}
